<!DOCTYPE html>
<html>
<head>
    <title>维修工单管理</title>
    #parse("sys/header.html")
    <style>
        .leftHeight {
            height: 85vh;
            overflow: auto;
        }
        .urgeCss {
            background-color: #ffc000;
        }
        .delCss {
            background-color: #d2cece;
        }
        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }
        .sugon_upload_btn {
            display: -webkit-inline-box;
            display: inline-block;
        }
        ::-webkit-scrollbar-thumb {
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
            background: #a8a5a5;
        }

        .workShop {
            position: absolute;
            top: 0;
            width: 80%;
            height: 25px;
            z-index: 2;
        }
        .leftMargin{
            margin-left: 5px;
        }
        .buttonTopBottom{
            margin-top: 5px;
            margin-bottom: 5px;
            display: flex;
        }
        .treeContent{
            height: 380px;
            overflow: scroll;
        }
        .buttonTops{
            margin-top: 5px;
        }
        .marginLs{
           padding-left: 20px;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="3">
                    <i-input type="text"  icon="md-arrow-dropdown-circle"
                             readonly="readonly"
                             v-model="workShopShow"
                             @on-click="deptTree" placeholder="请选择设备组织结构"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.repairCode" @on-enter="query" placeholder="报修编号"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.devCode" @on-enter="query" placeholder="设备编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.devName" @on-enter="query" placeholder="设备名称"></i-input>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.devStatus" placeholder="工单状态">
                        <i-option v-for="ticketStatus in ticketStatusList" :value="ticketStatus.value"
                                  :key="ticketStatus.value">{{ticketStatus.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.source" placeholder="来源">
                        <i-option v-for="sourceItem in sourceList" :value="sourceItem.value"
                                  :key="sourceItem.value">{{sourceItem.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.spareName" @on-enter="query" placeholder="备件名称"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.spareSpec" @on-enter="query" placeholder="备件规格"></i-input>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.delFlag" placeholder="工单是否删除">
                        <i-option v-for="ticketDelFlags in ticketDelFlagsList" :value="ticketDelFlags.value"
                                  :key="ticketDelFlags.value">{{ticketDelFlags.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <Date-picker type="daterange" v-model="repairStartRange" placement="bottom-end"
                                 placeholder="报修时间和维修开始时间区间" @on-change="handleRepairStartRangeChange"></Date-picker>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <Row :gutter="16" style="margin: 3px 0px 0px 0px;">
            <div class="buttons-group buttonTopBottom" >
                #if($shiro.hasPermission("devmaintenwork:export"))
                <i-button type="info" @click="exportData"><i class="fa fa-hand-o-up"></i>&nbsp;导出维修工单</i-button>
                #end
                #if($shiro.hasPermission("devmaintenwork:export"))
                <Upload ref="uploadFile"
                        action="../devRepairRecord/imports"
                        :format="['xlsx','xls']"
                        :before-upload="handleBeforeUpload"
                        :show-upload-list="false"
                        :on-success="handleSuccess" :on-error="handleError"
                        :on-format-error="handleFormatError" class="sugon_upload_btn">
                    <i-button class="leftMargin" type="primary"><i class="fa fa-hand-o-down"></i>&nbsp;导入</i-button>
                </Upload>
                #end
                #if($shiro.hasPermission("devmaintenwork:orderSure"))
                <i-button class="leftMargin" @click="orderSure" type="success" ><i class="fa fa-hand-o-right"></i>开始维修</i-button>
                #end
                #if($shiro.hasPermission("devmaintenwork:completed"))
                <i-button class="leftMargin" type="info" @click="completeRepair"><i class="fa fa-anchor"></i>&nbsp;结束维修</i-button>
                #end
                #if($shiro.hasPermission("devmaintenwork:check"))
                <i-button class="leftMargin" @click="report" type="primary" ><i class="fa fa-pencil"></i>上报</i-button>
                #end
                <i-button class="leftMargin" type="success"  @click="details"><i class="fa fa-eye"></i>查看</i-button>
                #if($shiro.hasPermission("devmaintenwork:delete"))
                <i-button class="leftMargin" type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
                #if($shiro.hasPermission("devmaintenwork:startOrder"))
                <i-button class="leftMargin" type="warning" @click="perfectRepairRecord"><i class="fa fa-pencil-square-o"></i> 完善/补录维修记录</i-button>
                #end
            </div>
        </Row>
        <Row :gutter="16" class-name="contentBlock">
           <div>
               <i-col :span="24" class="marginLs" style="padding-left: 15px">
                   <table id="jqGrid"></table>
               </i-col>
           </div>
        </Row>
    </div>
    <!-- 表单区域 -->
    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="devMaintenRepair" :rules="ruleValidate" :label-width="100">
            <row >
                <i-col :xs="12" :sm="12" :md="12" :lg="12" >
                    <Form-item required label="设备编号" prop="devCode">
                        <i-input v-model="devMaintenRepair.devCode" icon="md-arrow-dropdown-circle" @on-click="getDeviceInfo"
                                 placeholder="请选择故障设备"></i-input>
                    </Form-item>
                </i-col>
                <i-col :xs="12" :sm="12" :md="12" :lg="12" >
                    <Form-item label="设备名称" prop="devName">
                        <i-input disabled="true"  v-model="devMaintenRepair.devName" placeholder="设备选择后自动回填" disabled></i-input>
                    </Form-item>
                </i-col>
            </row>
            <row >
                <i-col :xs="11" :sm="11" :md="11" :lg="11">
                    <row>
                        <i-col :xs="8" :sm="8" :md="8" :lg="8" >
                            <Form-item label="报警分类" prop="vrtName" >
                                <i-input disabled="true" v-model="devMaintenRepair.vrtName" placeholder="设备选择后系统自动拉取" disabled></i-input>
                            </Form-item>
                        </i-col>
                        <i-col :xs="8" :sm="8" :md="8" :lg="8" v-show="flag != '-1'">
                            <Form-item :label-width="28" label="-">
                                <i-select placeholder="请选择VFG" @on-change="handleVfgChange" v-model="devMaintenRepair.vfgId" >
                                    <i-option v-for="vfg in vfgList" :value="vfg.id" :key="vfg.id">
                                        {{vfg.name}}
                                    </i-option>
                                </i-select>
                            </Form-item>
                        </i-col>
                        <i-col :xs="8" :sm="8" :md="8" :lg="8" v-show="flag != '-1'">
                            <Form-item :label-width="28" label="-" >
                                <i-select placeholder="请选择CCC" @on-change="handleCccChange" v-model="devMaintenRepair.cccId" >
                                    <i-option v-for="ccc in cccList" :value="ccc.id" :key="ccc.id">
                                        {{ccc.name}}
                                    </i-option>
                                </i-select>
                            </Form-item>
                        </i-col>
                    </row>
                </i-col>
            </row>
            <row>
                <i-col span="12" v-if="flag == 0">
                    <row>
                        <Form-item  label="报警代码" prop="faultId">
                            <div style="display: flex;">
                                <i-select v-model="devMaintenRepair.faultId">
                                    <i-option v-for="alarm in alarmList" :value="alarm.id" :key="alarm.id">{{alarm.alarmCode + ' ' + alarm.alarmDesc}}
                                    </i-option>
                                </i-select>
                                <div style="margin-left: 2px">
                                    <i-button type="info" @click="showLoc(0)" icon="md-arrow-round-forward">手动录入</i-button>
                                </div>
                            </div>
                        </Form-item>
                    </row>
                </i-col>
                <template v-if="flag == 1" >
                    <i-col span="12">

                        <Form-item label="报警代码" prop="faultCode" >
                            <i-input placeholder="请录入类似7001的报警代码，无则填写9999" v-model="devMaintenRepair.faultCode"  style="width: 85%"></i-input>
                            <i-button type="info" @click="showLoc(1)" icon="md-arrow-round-forward">已有选择</i-button>
                        </Form-item>
                    </i-col>
                    <i-col span="12">
                        <Form-item  label="报警描述" prop="faultDesc">
                            <i-input v-model="devMaintenRepair.faultDesc" placeholder="报警描述"></i-input>
                        </Form-item>
                    </i-col>
                </template>
            </row>
            <row>
                <template  v-if="flag == -1">
                    <i-col span="24">
                        <row>
                            <Form-item label-width="88" label="报警代码" prop="faultId">
                                <div style="display: flex;">
                                    <i-select
                                            v-model="devMaintenRepair.faultId"
                                            :filterable="true"
                                            :remote="true"
                                            :remote-method="remoteMethod2"
                                            :loading="loading2"
                                            placeholder="请输入至少3位报警代码"
                                    >
                                        <i-option v-for="(alarm,index) in searchAlarmList" :value="alarm.value" :key="index">{{alarm.label}}</i-option>
                                    </i-select>
                                </div>
                            </Form-item>
                        </row>
                    </i-col>
                </template>
            </row>
            <row>
                <i-col span="12">
                    <Form-item  label="开始维修" prop="startDateTime">
                        <Date-picker type="datetime" v-model="devMaintenRepair.startDateTime" format="yyyy-MM-dd HH:mm" placeholder="请选择开始维修时间"></Date-picker>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item  label="结束维修" prop="endDateTime">
                        <Date-picker type="datetime" v-model="devMaintenRepair.endDateTime" format="yyyy-MM-dd HH:mm" placeholder="请选择结束维修时间"></Date-picker>
                    </Form-item>
                </i-col>
            </row>
            <row>
                <i-col span="12">
                    <Form-item  label="故障描述" prop="recordDescr">
                        <i-input type="textarea" v-model="devMaintenRepair.recordDescr" placeholder="故障描述"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item  label="原因分析" prop="reason">
                        <i-input type="textarea" v-model="devMaintenRepair.reason" placeholder="原因"></i-input>
                    </Form-item>
                </i-col>
            </row>
            <row>
                <i-col span="12">
                    <Form-item  label="解决办法" prop="solution">
                        <i-input type="textarea" v-model="devMaintenRepair.solution" placeholder="解决办法"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="备注信息" prop="remark">
                        <i-input type="textarea" v-model="devMaintenRepair.remark" placeholder="请不要在此录入备件，请在换件记录中记录"></i-input>
                    </Form-item>
                </i-col>
            </row>
            #if($shiro.hasPermission("devmaintenrepair:update"))
            <row>
                <i-col span="12">
                    <Form-item>
                        <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                        <i-button type="warning" @click="reload" style="margin-left: 8px">返回</i-button>
                    </Form-item>
                </i-col>
            </row>
            #end
        </i-form>
    </Card>
    <!-- 选择故障类型-->
    <div id="faultTypeLayer" style="display: none;padding:10px;">
        <ul id="faultTypeTree" class="ztree"></ul>
    </div>
    <!--车间选择框-->
    <div id="workShopSubmit" class="treeContent" style="display: none;padding:10px;">
        <ul id="storeTree" class="ztree"></ul>
    </div>
</div>
<style>
    .from_tab_wide {
        width: 100% !important;
        padding-top: 1% !important;
    }
</style>
<script src="${rc.contextPath}/js/device/devRepairRecord.js?_${date.systemTime}"></script>
</body>
</html>
